package com.test.springboot3.springboot3testdemo1.health;

import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationRegistry;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： liuziyang
 * @date： 2024/8/7-下午4:19
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@Slf4j
@RequiredArgsConstructor
@Component
public class IndexObservation {
  private final ObservationRegistry observationRegistry;

  public void observe() {
    Observation.createNotStarted("indexObservation", this.observationRegistry)
        .lowCardinalityKeyValue("area", "cn")
        .highCardinalityKeyValue("userId", "10999")
        .observe(
            () -> {
              log.info("start observation...");
            });
  }
}
